#! /usr/bin/env python
# encoding=utf-8

from xml.sax import make_parser
from xml.sax.saxutils import XMLGenerator
 
class Handler(XMLGenerator):
	def startElement(self, name, attr):
		name = self.traducir(name)
		XMLGenerator.startElement(self, name, attr)
	
	def endElement(self, name):
		name = self.traducir(name)
		XMLGenerator.endElement(self, name)
	
	def traducir(self, name):
		return {
			'micasa': 'myhome',
			'habitacion': 'room',
			'mueble': 'forniture',
			'puerta': 'door'
		}[name]
      
parser = make_parser()
parser.setContentHandler(Handler(open('ej1-english.xml', 'w')))
parser.parse('ej1.xml')